import request from "@/utils/request";

// 获取优惠券列表
export function getCouponList(params, page = 1, pageSize = 10) {
  return request({
    url: `/coupon/list?pageNo=${page}&pageSize=${pageSize}`,
    method: "post",
    data: params,
  });
}

// 获取优惠券详情
export function getCouponDetail(id) {
  return request({
    url: `/coupon/getDetailById?theId=${id}`,
    method: "post",
  });
}

// 新增或者编辑优惠券
export function addOrEditCoupon(data) {
  return request({
    url: "/coupon/saveUpdate",
    method: "post",
    data,
  });
}

// 删除优惠券
export function deleteCoupon(id) {
  return request({
    url: `/coupon/deleteByStatus?theId=${id}`,
    method: "post",
  });
}

/**
 * 删除用户优惠券
 */
export function deleteUserCoupon(id) {
  return request({
    url: `/customerCoupon/deleteByStatus?theId=${id}`,
    method: "post",
  });
}

/**
 *
 * 获取用户优惠券列表
 *
 */
export function getUserCouponList(params, page = 1, pageSize = 10) {
  return request({
    url: `/customerCoupon/list?pageNo=${page}&pageSize=${pageSize}`,
    method: "post",
    data: params,
  });
}

/**
 *
 * 赠送用户优惠券
 *
 */
export function giveUserCoupon(data) {
  return request({
    url: "/customerCoupon/saveUpdate",
    method: "post",
    data,
  });
}
